
package com.zmn.oms.task.listener;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zmn.consts.GlobalConsts;
import com.zmn.manager.mq.annotation.AliyunMQHandler;
import com.zmn.manager.mq.annotation.AliyunMQListener;
import com.zmn.oms.common.constant.MessageQueueTagConsts;
import com.zmn.oms.zmn.business.interfaces.collectionnotpay.CollectionNotPayBService;
import com.zmn.pay.gateway.common.model.dro.PayOrderDRO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Objects;


/**
 * 类描述：工单
 *
 * @author lujia
 * @date 2018/11/30 16:53
 */

@Slf4j
@AliyunMQListener(topic = "${spring.mq.topic.oms}")
@Component
public class OrderSendPayBreakContractAmountListener {
    @Resource
    private CollectionNotPayBService collectionNotPayBService;

    @AliyunMQHandler(tags = MessageQueueTagConsts.ZMN_TAG_PAY_BREAK_CONTRACT_AMOUNT)
    public void retryPayBreakContractAmount(String message) {
        log.info("orderSendPayBreakContractAmountListener:zmn_tag_pay_break_contract_amount:message={}", message);
        // 获取消息参数
        JSONObject jsonObject = JSON.parseObject(message);
        Integer amount = jsonObject.getInteger("amount");
        Long workId = jsonObject.getLong("workId");
        Long orderId = jsonObject.getLong("orderId");
        if (Objects.nonNull(workId) || Objects.nonNull(orderId) || Objects.nonNull(amount)) {
            collectionNotPayBService.retryPayBreakContractAmount(workId, orderId, amount);
        } else {
            log.error("orderSendPayBreakContractAmountListener:zmn_tag_pay_break_contract_amount:error: 工单ID,超时类型为空");
        }
    }
}

